function bindWeaponKeys()
	bindKey(source, "M", "down", dropWeapon)
end

function dropWeapon(thePlayer)
	if getPedWeapon(thePlayer) ~= 0 then
		local playerx, playery, playerz = getElementPosition(thePlayer)
		local npickup = createPickup(playerx + 3, playery, playerz, 2, getPedWeapon(thePlayer), 0, getPedAmmoInClip(thePlayer))
		setWeaponAmmo(thePlayer, getPedWeapon(thePlayer), 0)
		takeWeapon(thePlayer, getPedWeapon(thePlayer))
		addEventHandler("onPickupUse", npickup, destroyPickup)
	end
end

function destroyPickup()
	destroyElement(source)
end


addEventHandler("onPlayerSpawn", getRootElement(), bindWeaponKeys)
--addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), bindWeaponKeys)